//
//  4-9.cpp
//  mm
//
//  Created by  AbbyCin on 12/16/14.
//  Copyright (c) 2014  AbbyCin. All rights reserved.
//

#include <iostream>

struct candybar {
    char brand[20];
    float mass;
    int calories;
};

int main()
{
    using namespace std;
    
    candybar *snack = new candybar[3];
    // in a comlex way
    for(int i=0; i<3; i++)
    {
        cout << "brand: "; cin.getline((snack + i)->brand, 20) ; cout << endl;
        cout << "mass: "; cin >> (snack + i)->mass; cout << endl;
        cout << "calories: "; (cin >> (snack + i)->calories).get(); cout << endl; // cin.get() is paramount
    }
    
    for(int i=0; i<3; i++)
    {
        cout << "brand: " << (snack + i)->brand << endl;
        cout << "mass: " << (snack + i)->mass << endl;
        cout << "calories: " << (snack + i)->calories << endl;
    }
    
    delete [] snack;
    
    return 0;
}
